import { messages } from "share/common";
import React from 'react'
import { connect } from 'react-redux'
import { Tabs } from 'antd'
const TabPane = Tabs.TabPane;
import EmailNotification from "containers/setting/email-notification/email-notification";
import EmailTemplate from "containers/setting/email-notification/email-template";

class EmailSetting extends React.Component{
  constructor(props) {
    super(props);
    this.state = {
      tabs: [
        {key: 'print', name: messages('setting.key488')/*打印邮件通知*/},
        {key: 'template', name: messages('setting.key2159')/*审批邮件通知*/}
      ],
      nowTab: 'print'
    }
  }

  componentDidMount(){}

  renderTabs() {
    const { tabs } = this.state;
    return (
      tabs.map(tab => {
        return <TabPane tab={tab.name} key={tab.key}>{this.renderComponents(tab.key)}</TabPane>
      })
    )
  }

  renderComponents = (key) => {
    switch(key){
      case 'print':
        return <EmailNotification />;
      case 'template':
        return <EmailTemplate />;
    }
  };

  //Tabs点击
  onChangeTabs = (key) => {
    this.setState({nowTab : key});
  };

  render() {
    const { nowTab } = this.state;
    return (
      <div>
        <Tabs type="line" onChange={this.onChangeTabs} tabPosition="left" activeKey={nowTab}>
          {this.renderTabs()}
        </Tabs>
      </div>
    )
  }
}

EmailSetting.contextTypes = {
  router: React.PropTypes.object
};

function mapStateToProps(state) {
  return {}
}

export default connect(mapStateToProps)(EmailSetting)
